ARG 7.4
FROM php:7.4-fpm-alpine
ENV TIMEZONE Asia/Shanghai
# 阿里云源
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories && \
apk update && \
apk add tzdata curl && \
#设置docker时间
cp /usr/share/zoneinfo/${TIMEZONE} /etc/localtime && \
echo "${TIMEZONE}" > /etc/timezone
#
RUN apk --update --repository=http://dl-4.alpinelinux.org/alpine/edge/testing add sudo curl curl-dev postgresql-dev shadow busybox-suid procps
RUN apk add --no-cache autoconf g++ libtool make curl-dev libxml2-dev linux-headers libzip-dev libmcrypt-dev

RUN docker-php-ext-install bcmath pcntl pdo_mysql mysqli curl zip pcntl

#php7.1 之后 Mcrypt 扩展 不在维护
RUN pecl install mcrypt-1.0.3 \
    && docker-php-ext-enable mcrypt


# #Composer
RUN curl -sS https://getcomposer.org/installer | php \
    && mv composer.phar /usr/local/bin/composer \
    && composer self-update --clean-backups \
    && composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/

#安装 php GD
 RUN apk add --no-cache libwebp-dev freetype-dev libjpeg-turbo-dev libpng-dev \
    && docker-php-ext-configure gd --with-webp=/usr/include/webp --with-jpeg=/usr/include --with-freetype=/usr/include/freetype2 \
    && docker-php-ext-install  gd
#Swoole
#ARG PHP_SWOOLE=false
#RUN if [ ${PHP_SWOOLE} != false ]; then \
#    curl -O http://pecl.php.net/get/swoole-${PHP_SWOOLE}.tgz -L \
#    && (tar -zxvf swoole-${PHP_SWOOLE}.tgz && cd swoole-${PHP_SWOOLE} && phpize && ./configure --enable-openssl && make && make install) \
#    && docker-php-ext-enable swoole \
#;fi

# XDEBUG
ARG PHP_XDEBUG=false
RUN if [ ${PHP_XDEBUG} != false ]; then \
    curl -O http://pecl.php.net/get/xdebug-${PHP_XDEBUG}.tgz -L \
    && pecl install xdebug-${PHP_XDEBUG}.tgz \
    && docker-php-ext-enable xdebug \
;fi

# REDIS
ARG PHP_REDIS=6.0.2
RUN if [ ${PHP_REDIS} != false ]; then \
    curl -O http://pecl.php.net/get/redis-${PHP_REDIS}.tgz -L \
    && pecl install redis-${PHP_REDIS}.tgz \
    && docker-php-ext-enable redis \
;fi

# PDO_SQLSRV
# ARG PHP_SQLSRV=false
# RUN if [ ${PHP_SQLSRV} != false ]; then \
#     curl -O http://pecl.php.net/get/pdo_sqlsrv-${PHP_SQLSRV}.tgz -L \
#     && pecl install pdo_sqlsrv-${PHP_SQLSRV}.tgz \
#     && docker-php-ext-enable pdo_sqlsrv \
# ;fi

WORKDIR /var/www/html

RUN  groupadd -g 8009 www-data && \
 useradd -u 8009 -g www-data  www-data && \
 chown -R www-data:www-data /var/www/html
